Skip to content

upgrade Pinterest-Generated-Client to 0.1.11; fix: support single-e… - #176

Merged
dfana01 merged 1 commit into
pinterest:mainfrom
munds:bump-generated-client-0.1.11
Aug 26, 2026
Merged

upgrade Pinterest-Generated-Client to 0.1.11; fix: support single-e…#176
dfana01 merged 1 commit into
pinterest:mainfrom
munds:bump-generated-client-0.1.11

Conversation

@munds

@munds munds commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Problem (Why)

Pinterest-Generated-Client 0.1.11 models ads bulk responses with a single exception object on each item (exceptions is not always a list). Campaigns and ad groups still return a list. verify_api_response only treated list-shaped exceptions, so ads failures were not turned into SdkException.

Campaign create also now expects campaign-budget optimization on awareness campaigns, and some validation errors surface as raw ApiException (HTTP 400) instead of the SDK wrappers the tests assumed. Organic cleanup failed on protected boards (401) that cannot be deleted.

Solution (What + How)

  • Bump Pinterest-Generated-Client from 0.1.10 to 0.1.11.
  • Refactor verify_api_response to read exceptions as either a list or a single object, on both dict and generated-model responses, then raise SdkException when code and message are present.
  • Integration tests: set is_campaign_budget_optimization=True on awareness campaign creates; accept ApiException where the API now validates earlier; skip protected boards in organic cleanup.
  • Document conversion-token and fixture env vars in .env.example.

Test Plan

  • python -m pytest tests/src/pinterest/utils/test_error_handling.py — list exceptions, single-object ads exceptions, and dict responses all raise SdkException
  • Ads integration tests: campaign/ad group/keyword create and update (including invalid tracking URLs and missing match_type)
  • Organic cleanup: remaining boards are only the default fixture board and/or PROTECTED boards

…xception API responses and update integration tests
@munds

munds commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Integration tests passing proof:

(.venv) {10:49}~/Code/repos/pinterest-python-sdk:bump-generated-client-0.1.11 ✓ ➭ make integration_tests
cleaning organic data...
python -m pytest ./integration_tests/clean_organic_data.py
/Users/amundayoor/Code/repos/pinterest-python-sdk/.venv/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
============================================================================================================================ test session starts =============================================================================================================================
platform darwin -- Python 3.9.6, pytest-7.1.2, pluggy-1.6.0
rootdir: /Users/amundayoor/Code/repos/pinterest-python-sdk, configfile: pytest.ini
plugins: requests-mock-1.8.0, cov-7.1.0
collected 1 item

integration_tests/clean_organic_data.py .                                                                                                                                                                                                                              [100%]

============================================================================================================================= 1 passed in 1.23s ==============================================================================================================================
integration tests...
python -m pytest --ignore=clean_organic_data.py --cov ./pinterest/ --cov-branch ./integration_tests/ --cov-report term-missing
/Users/amundayoor/Code/repos/pinterest-python-sdk/.venv/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
============================================================================================================================ test session starts =============================================================================================================================
platform darwin -- Python 3.9.6, pytest-7.1.2, pluggy-1.6.0
rootdir: /Users/amundayoor/Code/repos/pinterest-python-sdk, configfile: pytest.ini
plugins: requests-mock-1.8.0, cov-7.1.0
collected 94 items

integration_tests/test_pinterest_base_model.py ...........                                                                                                                                                                                                             [ 11%]
integration_tests/ads/test_ad_accounts.py .....                                                                                                                                                                                                                        [ 17%]
integration_tests/ads/test_ad_groups.py ..........                                                                                                                                                                                                                     [ 27%]
integration_tests/ads/test_ads.py ........                                                                                                                                                                                                                             [ 36%]
integration_tests/ads/test_audiences.py ....                                                                                                                                                                                                                           [ 40%]
integration_tests/ads/test_campaigns.py ...........                                                                                                                                                                                                                    [ 52%]
integration_tests/ads/test_conversion_events.py ..                                                                                                                                                                                                                     [ 54%]
integration_tests/ads/test_conversion_tags.py ......                                                                                                                                                                                                                   [ 60%]
integration_tests/ads/test_customer_lists.py .........                                                                                                                                                                                                                 [ 70%]
integration_tests/ads/test_keywords.py ....                                                                                                                                                                                                                            [ 74%]
integration_tests/client/test_client.py .....                                                                                                                                                                                                                          [ 79%]
integration_tests/organic/test_boards.py ..........s...                                                                                                                                                                                                                [ 94%]
integration_tests/organic/test_pins.py .....                                                                                                                                                                                                                           [100%]

=============================================================================================================================== tests coverage ===============================================================================================================================
______________________________________________________________________________________________________________ coverage: platform darwin, python 3.9.6-final-0 _______________________________________________________________________________________________________________

Name                                      Stmts   Miss Branch BrPart  Cover   Missing
-------------------------------------------------------------------------------------
pinterest/__init__.py                         1      0      0      0   100%
pinterest/ads/__init__.py                     0      0      0      0   100%
pinterest/ads/ad_accounts.py                 59      1      0      0    98%   221
pinterest/ads/ad_groups.py                  157      3     14      4    96%   320->323, 361, 363, 421
pinterest/ads/ads.py                        163      4     12      5    95%   394, 396, 398, 428, 429->431
pinterest/ads/audiences.py                   82      2      6      3    94%   162->164, 165, 231
pinterest/ads/campaigns.py                  130     14      6      2    88%   345, 377-389, 401-413, 422, 431, 445-446, 498
pinterest/ads/conversion_events.py           17      0      0      0   100%
pinterest/ads/conversion_tags.py             80      4      2      1    94%   261, 309-314
pinterest/ads/customer_lists.py              78      0      0      0   100%
pinterest/ads/keywords.py                    71      2      4      2    95%   122, 186
pinterest/bin/__init__.py                     0      0      0      0   100%
pinterest/bin/get_config.py                  11     11      4      0     0%   4-29
pinterest/client/__init__.py                 73     11     12      5    81%   33, 36-41, 43->46, 80, 92-96, 113, 119
pinterest/config.py                          26      0      0      0   100%
pinterest/organic/__init__.py                 0      0      0      0   100%
pinterest/organic/boards.py                 147      9     18      7    90%   70, 151, 183, 289, 319, 352, 398, 440, 548
pinterest/organic/pins.py                   132     19     18      2    78%   176, 240, 279, 361-383
pinterest/utils/__init__.py                   0      0      0      0   100%
pinterest/utils/base_model.py                87      7     30      2    91%   44, 47-50, 204, 210
pinterest/utils/bookmark.py                  20      5      4      2    71%   47, 49-51, 61
pinterest/utils/error_handling.py            24      2     12      2    89%   34, 59
pinterest/utils/load_json_config.py          31      5     12      3    77%   19, 35-38, 49
pinterest/utils/refresh_access_token.py      17      2      6      2    83%   57, 62
pinterest/utils/sdk_exceptions.py            18      2      6      2    83%   24, 27
pinterest/version.py                          1      0      0      0   100%
-------------------------------------------------------------------------------------
TOTAL                                      1425    103    166     44    90%
================================================================================================================= 93 passed, 1 skipped in 211.74s (0:03:31) ==================================================================================================================

@dfana01
dfana01 merged commit 0748020 into pinterest:main Aug 26, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants